import React ,{Suspense}from 'react'
import {Route,Routes,BrowserRouter,Navigate} from 'react-router-dom'
import config from './config'
interface VIE{
    path:string;
    component?:any;
    children?:VIE[],
    to?:string;
}
export default function Vie() {
   const ly=(arr:VIE[])=>{
    return   arr.map((a,b)=>{
            return <Route key={b} path={a.path} 
            element={a.to?<Navigate to={a.to}/>:<a.component></a.component>}>
            {a.children&&ly(a.children)}
            </Route>
        })
    }
  return (
    <BrowserRouter>Vie
    <Suspense fallback='加载中'>
        <Routes>
        {ly(config)}
        </Routes>
    </Suspense>
    </BrowserRouter>
  )
}
